
const moment = require("moment");
const today = new Date(); // 获取当前日期
const day = today.getDay(); // 获取今天是星期几
const termStamp = new Date(2024, 1, 26).getTime()
const dayStamp = 24 * 60 * 60

/**
 * 
 * @returns 格式化本周周一的时间
 */

export function getMonday() {
  const Monday = new Date(today);  //备份当前时间
  Monday.setDate(today.getDate() - day + (day === 0 ? -6 : 1));  //计算周一的时间
  return moment(Monday.getTime()).format("YYYY/MM/DD");  //使用moment库格式化时间戳
}

/**
 * 
 * @returns 格式化本周周末的时间
 */
export function getSunday() {
    const Sunday = new Date(today) 
    Sunday.setDate(today.getDate() + 7 - day)
    return moment(Sunday.getTime()).format("YYYY/MM/DD");
}

export function CourseDataFormat(week, dayofWeek){
    console.log("第",week,"周","周",dayofWeek)
    const stamp = termStamp/1000 + ((week - 1) * 7 + (dayofWeek - 1)) * dayStamp
    return moment(new Date(stamp * 1000)).format("YYYY/MM/DD")
}
